package com.netstar.salesman_90dsp.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * 今日工作model
 * 
 * @author zhangshuai
 * 
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class TodayWorkModel implements Parcelable {
	/**
	 * 当在intent传递时，的key
	 */
	public static final String INTENT_KEY = "TodayWorkModel";
	/**
	 * 工作id
	 */
	private String id;
	/**
	 * 工作登记时间
	 */
	private String planDate;
	/**
	 * 工作内容
	 */
	private String plans;
	/**
	 * 工作完成状态，：state(0:未完成；1:完成)，默认为0
	 */
	private String state = "0";

	/**
	 * 自己添加用，只要日期
	 * 
	 * @param planDate
	 */
	public String getPlanDateOnlyDate() {
		String value = null;
		try {
			value = getPlanDate().substring(0, 10);
		} catch (Exception e) {
			value = null;
			e.printStackTrace();
		}
		return value;
	}

	public String getId() {
		return id;
	}

	@JsonProperty("id")
	public void setId(String id) {
		this.id = id;
	}

	public String getPlanDate() {
		return planDate;
	}

	@JsonProperty("plandate")
	public void setPlanDate(String planDate) {
		this.planDate = planDate;
	}

	public String getPlans() {
		return plans;
	}

	@JsonProperty("plans")
	public void setPlans(String plans) {
		this.plans = plans;
	}

	public String getState() {
		return state;
	}

	@JsonProperty("state")
	public void setState(String state) {
		this.state = state;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(id);
		dest.writeString(planDate);
		dest.writeString(plans);
		dest.writeString(state);
	}

	public static final Parcelable.Creator<TodayWorkModel> CREATOR = new Creator<TodayWorkModel>() {

		@Override
		public TodayWorkModel createFromParcel(Parcel source) {
			return new TodayWorkModel(source);
		}

		@Override
		public TodayWorkModel[] newArray(int size) {
			return new TodayWorkModel[size];
		}

	};

	public TodayWorkModel() {

	}

	private TodayWorkModel(Parcel source) {
		id = source.readString();
		planDate = source.readString();
		plans = source.readString();
		state = source.readString();
	}

	@Override
	public boolean equals(Object o) {
		boolean isEqual = false;
		if (o == null || TextUtils.isEmpty(id)
				|| TextUtils.isEmpty(o.toString())) {
			isEqual = false;
		} else if (id.equals(o.toString())) {
			isEqual = true;
		}
		return isEqual;
	}

	@Override
	public String toString() {
		return id;
	}

}